package cn.zl.web.dto.virtualvideostream;

import cn.yunbamboos.rest.service.anno.param.ParamType;
import cn.yunbamboos.rest.service.anno.param.enums.Type;
import cn.yunbamboos.rest.service.dto.in.FileInDTO;
import com.alibaba.fastjson2.JSONObject;
import jakarta.validation.constraints.NotNull;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

public class AddVirtualVideoStreamInDTO extends FileInDTO {

    @NotNull(message = "流的应用名不能为空")
    @ParamType(path = "app", type = Type.String, title = "流的应用名", required = true)
    private String app;
    @NotNull(message = "流的名称不能为空")
    @ParamType(path = "stream", type = Type.String, title = "流的名称", required = true)
    private String stream;

    private Map<String, MultipartFile> files;

    @Override
    public void decodeFile(JSONObject json, Map<String, MultipartFile> files) {
        this.app = json.getString("app");
        this.stream = json.getString("stream");
        this.files = files;
    }

    public int getFileSize() {
        if (files == null) {
            return 0;
        }
        return files.size();
    }

    public String getApp() {
        return app;
    }

    public String getStream() {
        return stream;
    }

    public Map<String, MultipartFile> getFiles() {
        return files;
    }

    public MultipartFile getFile(String key) {
        return files.get(key);
    }


}
